package com.ruoyi.web.controller.djb;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.djb.domain.DjbUserLimit;
import com.ruoyi.djb.service.IDjbUserLimitService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户限制Controller
 * 
 * @author xxd
 * @date 2024-11-05
 */
@Controller
@RequestMapping("/djb/userLimit")
public class DjbUserLimitController extends BaseController
{
    private String prefix = "djb/userLimit";

    @Autowired
    private IDjbUserLimitService djbUserLimitService;

    @RequiresPermissions("djb:userLimit:view")
    @GetMapping()
    public String userLimit()
    {
        return prefix + "/userLimit";
    }

    /**
     * 查询用户限制列表
     */
    @RequiresPermissions("djb:userLimit:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjbUserLimit djbUserLimit)
    {
        startPage();
        List<DjbUserLimit> list = djbUserLimitService.selectDjbUserLimitList(djbUserLimit);
        return getDataTable(list);
    }

    /**
     * 导出用户限制列表
     */
    @RequiresPermissions("djb:userLimit:export")
    @Log(title = "用户限制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjbUserLimit djbUserLimit)
    {
        List<DjbUserLimit> list = djbUserLimitService.selectDjbUserLimitList(djbUserLimit);
        ExcelUtil<DjbUserLimit> util = new ExcelUtil<DjbUserLimit>(DjbUserLimit.class);
        return util.exportExcel(list, "用户限制数据");
    }

    /**
     * 新增用户限制
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户限制
     */
    @RequiresPermissions("djb:userLimit:add")
    @Log(title = "用户限制", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjbUserLimit djbUserLimit)
    {
        return toAjax(djbUserLimitService.insertDjbUserLimit(djbUserLimit));
    }

    /**
     * 修改用户限制
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DjbUserLimit djbUserLimit = djbUserLimitService.selectDjbUserLimitById(id);
        mmap.put("djbUserLimit", djbUserLimit);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户限制
     */
    @RequiresPermissions("djb:userLimit:edit")
    @Log(title = "用户限制", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjbUserLimit djbUserLimit)
    {
        return toAjax(djbUserLimitService.updateDjbUserLimit(djbUserLimit));
    }

    /**
     * 删除用户限制
     */
    @RequiresPermissions("djb:userLimit:remove")
    @Log(title = "用户限制", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(djbUserLimitService.deleteDjbUserLimitByIds(ids));
    }
}
